<template>
  <div>
    <h3 style="text-align: center">供应订单记录</h3>
    <form style="text-align: right">
      <el-button type="primary" @click="search">查询</el-button>
    </form>
    <el-table
        :data="purchaseOrderAry"
        style="width: 100%">
      <el-table-column
          prop="purchaseId"
          label="采购id"
          width="100">
      </el-table-column>
      <el-table-column
          prop="purchaseOrderNumber"
          label="采购订单编号"
          width="200">
      </el-table-column>
      <el-table-column
          prop="supplierId"
          label="供应商id"
          width="100">
      </el-table-column>
      <el-table-column
          prop="totalAmount"
          label="总数量"
          width="150">
      </el-table-column>
      <el-table-column
          prop="totalPrice"
          label="总金额(元)"
          width="150">
      </el-table-column>
      <el-table-column
          prop="gatherTag"
          label="入库标志"
          width="150">
        <template slot-scope="scope">
          <span v-if="scope.row.gatherTag=='K001-1'">等待入库</span>
          <span v-else-if="scope.row.gatherTag=='K001-2'">入库失败</span>
          <span v-else>入库成功</span>
        </template>
      </el-table-column>
      <el-table-column
          prop="payMethod"
          label="支付方式"
          width="150">
        <template slot-scope="scope">
          <span v-if="scope.row.payMethod=='P002-1'">余额支付</span>
          <span v-else-if="scope.row.payMethod=='P002-2'">微信支付</span>
          <span v-else>现金支付</span>
        </template>
      </el-table-column>
      <el-table-column
          prop="conveyTag"
          label="配送标志"
          width="150">
        <template slot-scope="scope">
          <span v-if="scope.row.conveyTag=='P001-1'">待发货</span>
          <span v-else-if="scope.row.conveyTag=='P001-2'">待收货</span>
          <span v-else>已收货</span>
        </template>
      </el-table-column>
    </el-table>
    <!--  分页工具-->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data(){
    return{
      //当前页号
      currentPage: 1,
      //总记录数
      total: 0,
      //当前页大小
      pageSize: 5,
      //页大小列表
      pageSizes: [2, 5, 10, 20],
      //供应订单记录数组
      purchaseOrderAry: []
    }
  },
  methods:{
    handleSizeChange(val) {
      this.pageSize = val
      this.getPurchaseOrder()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.getPurchaseOrder()
    },
    search(){
      this.pageNo=1
      this.getPurchaseOrder()
    },
    // 分页查询供应订单记录
    async getPurchaseOrder(){
      const {data:res}=
          await this.$http.post(`/community/purchaseOrder/checkedList?pageNo=`+this.currentPage+`&pageSize=`+this.pageSize)
      // console.log(res)
      this.purchaseOrderAry = res.rows
      this.total = res.total
    }
  }
}
</script>

<style scoped>

</style>